package losrebellos.lospistoleros.components.application.sprite 
{
	import losrebellos.lospistoleros.components.application.IAbstractPApplicationModel;
	import losrebellos.lospistoleros.core.model.sprite.PModelSprite;
	import losrebellos.lospistoleros.vo.StageVO;

	import flash.display.LoaderInfo;
	import flash.errors.IllegalOperationError;

	/*
	 *
	 * @author los rebellos - ben@benoitvinay.com
	 *
	 */
	public class AbstractPApplicationModelSprite extends PModelSprite implements IAbstractPApplicationModel
	{
		/*
		 *
		 * VARIABLES
		 *
		 */
		protected var _loaderInfo:LoaderInfo = null;
		protected var _parameters:Object = null;
		protected var _stageVO:StageVO = null;
		
		
		/*
		 *
		 * CONSTRUCTOR
		 *
		 */
		public function AbstractPApplicationModelSprite(name:String = null, type:String = null)
		{
			super(name, type);
		}
		
		
		/*
		 * 
		 * FLASH VARS
		 * 
		 */
		public function set loaderInfo(value:LoaderInfo):void
		{
			_loaderInfo = value;
			_parameters = _loaderInfo.parameters;
		}
		public function getFlashVars(name:String):Object
		{
			return _parameters[name];
		}

		
		/*
		 * 
		 * STAGE
		 * 
		 */
		protected function createStageVO():StageVO
		{
			throw new IllegalOperationError(">>> AbstractPApplicationModelSprite:createStageVO need to be overridden");
			
			return null;
		}
		public function get stageVO():StageVO
		{
			if(!_stageVO)
			{
				_stageVO = createStageVO();
			}
			
			return _stageVO;
		}
	}
}